<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<html class="x-admin-sm">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<head>
<meta charset="UTF-8">
<title>仓库管理</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/font.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/css/login.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/css/xadmin.css">
<script type="text/javascript"
	src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/lib/layui/layui.js" charset="utf-8"></script>
</head>
<body class="login-bg" onkeydown="keyOnClick(event);">
	<div class="login layui-anim layui-anim-up">
		<div class="message">仓库管理登录</div>
		<div id="darkbannerwrap"></div>
		<form class="layui-form">
			<input name="userName" placeholder="用户名" type="text"
				lay-verify="required" class="layui-input">
			<hr class="hr15">
			<input name="passWord" lay-verify="required" placeholder="密码"
				type="password" class="layui-input">
			<hr class="hr15">
			<input value="登录" class="login_btn" lay-submit lay-filter="login"
				style="width: 100%;" type="button"
				οnkeydοwn="javascript:if(event.keyCode==13) document.getElementsByClassName('login_btn').click();">
			<hr class="hr20">
		</form>
	</div>
	<script>
		// 点击登录按钮
		$('.login_btn').click(function(){
			$.ajax({
				url : '<%=basePath%>/ajaxLogin',
				type : 'GET',
				data : $('.layui-form').serialize(),
				async: false,
				dataType: "json",
				success: function (data) {
					if (data.errCode == 200) {
						window.location.href = "<%=basePath%>toindex";
					} else {
						alert(data.errMsg);
					}
				},
				error : function(data) {
					alert(data.msg);
				}
			});
		});

		function keyOnClick(e) {
			var theEvent = window.event || e;
			var code = theEvent.keyCode || theEvent.which;
			//回车键的键值为13
			if (code == 13) {
				//调用搜索事件
				search();
			}
		}

		function search() {
	        $(".login_btn").click();
	    }

		function kickout(){
			var kickout='${kickout}';
			if(kickout){
				alert("您的账号在另一台设备上登录！");
			}
		}
		window.onload=kickout();
	</script>
</body>
</html>